package com.example.rmi.server;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import com.example.rmi.remote.IHelloService;
import com.example.rmi.remote.impl.HelloService;

public class RemoteServer {
	public static void main(String... args){
		Registry registry = null;
		
		try{
			
			System.out.println(IHelloService.class.getProtectionDomain().getCodeSource().getLocation().toString());
			
			
			//registry = LocateRegistry.getRegistry(7001);
			
			//System.setProperty("java.rmi.server.codebase", IHelloService.class.getProtectionDomain().getCodeSource().getLocation().toString());
			registry = LocateRegistry.createRegistry(7001);
			
			//registry.rebind("helloService", UnicastRemoteObject.exportObject(new HelloService(), 7001));
			registry.rebind("helloService", new HelloService());
			
		} catch(RemoteException e){
			e.printStackTrace();
		}
	}
}